<?php
	
	session_start();

	require "connect.inc.php";

	$stmt = $pdo->prepare("select * from login where username = ? and password = ?");    
    
	$stmt->execute(array($_POST["username"],md5($_POST["password"])));


     //rowCount()用于select语句时，可能会失效
	if($_SESSION = $stmt -> fetch(PDO::FETCH_ASSOC)){
		$_SESSION["islogin"] = 1;

	}else{
		$_SESSION["islogin"] = 0;

	}

	$data['result'] = $_SESSION['islogin'];
	$data['session_id'] = session_id();
	$data['username'] = $_SESSION['username'];

	$data=json_encode($data);

	echo $data;



?>